package jee.boot.entity.auth;

import jee.boot.common.annotation.Column;
import jee.boot.common.annotation.Table;
import jee.boot.common.basic.TreeEntity;

/**
 * 组织
 */
@Table(name = "tt_organization")
public class Organization extends TreeEntity<Organization> {
    private static final long serialVersionUID = 1L;
    /**
     * 父类
     */
    @Column(name = "parent_id", data = {"parent.id", "parent.name", "parent.code"})
    private Organization parent;
    @Column(ignoreAlias = true, name = "(select count(1) from tt_organization child where child.parent_id=a.id)", action = Column.Action.QUERY)
    private Integer childNum = 0;
    @Column(ignoreAlias = true, name = "(select ifnull(max(child.level)-a.level,0) from tt_organization child where child.parent_ids like  CONCAT('%',a.id,',%'))", action = Column.Action.QUERY)
    private Integer childDeep = 0;
    private String code;
    private String category;
    private String type;
    private String grade;
    private String address;
    private String zipCode;
    private String master;
    private String phone;
    private String fax;
    private String email;


    public Organization() {
    }

    public Organization(String id) {
        super(id);
    }

    @Override
    public Organization getParent() {
        return parent;
    }

    @Override
    public void setParent(Organization parent) {
        this.parent = parent;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getZipCode() {
        return zipCode;
    }

    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    public String getMaster() {
        return master;
    }

    public void setMaster(String master) {
        this.master = master;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getChildNum() {
        return childNum;
    }

    public void setChildNum(Integer childNum) {
        this.childNum = childNum;
    }

    public Integer getChildDeep() {
        return childDeep;
    }

    public void setChildDeep(Integer childDeep) {
        this.childDeep = childDeep;
    }

    public static void main(String[] args) {
        System.out.println(new Organization().getFindListSql());
    }
}
